<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDistributionOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('distribution_orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('order_id')  ->default(0)->comment('订单id');
            $table->string('order_num')     ->default('')->comment('订单号');
            $table->decimal('amount')       ->default(0)->comment('价格');
            $table->bigInteger('buyer_user_id')->default(0)->comment('下单用户');
            $table->bigInteger('signed_user_id') ->default(0)->comment('签约分销商');
            $table->bigInteger('first_user_id') ->default(0)->comment('一级返佣接收人');
            $table->bigInteger('second_user_id')->default(0)->comment('二级返佣接收人');
            $table->bigInteger('third_user_id')->default(0)->comment('三级返佣接收人');
            $table->integer('success')       ->default(0)->comment('0未完成，1已完成，2已取消');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('distribution_orders');
    }
}
